﻿/*
	Copyright 2010 Intuitive Solutions

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

	   http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/

using System;
using Metamorph.Configuration;

namespace Metamorph.Core.Monitoring
{
	public class MonitoringManager
	{
		private static MonitoringManager mInstance;

		private IBamClient bcBamClient;

		public MonitoringManager()
		{
		}

		public static MonitoringManager Instance
		{
			get
			{
				if (mInstance == null)
				{
					mInstance = new MonitoringManager();
				}

				return mInstance;
			}
		}

		public IBamClient BamClient
		{
			get
			{
				return bcBamClient;
			}
		}

		public void StartMonitoring()
		{
			if (MetamorphConfiguration.Instance.MonitoringProvider.Server.Enabled)
			{
				IBamService bsBamService = (IBamService)AssemblyUtils.Instance.GetServerMonitoringAssembly().CreateInstance(MetamorphConfiguration.Instance.MonitoringProvider.AssemblyBaseName + ".Server.BamService");
				bsBamService.Start();
			}

			if (Metamorph.Configuration.MetamorphConfiguration.Instance.MonitoringProvider.Client.Enabled)
			{
				bcBamClient = (IBamClient)AssemblyUtils.Instance.GetClientMonitoringAssembly().CreateInstance(MetamorphConfiguration.Instance.MonitoringProvider.AssemblyBaseName + ".Client.BamClient");
				bcBamClient.Start();
			}
		}
	}
}
